package com.prs.crm.dao.document.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import com.prs.crm.context.AppContext;
import com.prs.crm.dao.document.DraftTypeDao;
import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.domain.document.DraftType;

public class DraftTypeDaoImpl  extends BaseDaoImpl<DraftType> implements DraftTypeDao{

	@SuppressWarnings("unchecked")
	@Override
	public List<DraftType> getAllDraftType() {
		Criteria criteria=this.getSession().createCriteria(DraftType.class);
		criteria.add(Restrictions.like("usePerson", "%"+AppContext.getAccountContext().currentUser().getResume().getName()+"%"));
		return criteria.list();
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<DraftType> getDraftTypes() {
		Criteria criteria=this.getSession().createCriteria(DraftType.class);
		return criteria.list();
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<DraftType> getDraftTypeByName(String type) {
		Criteria criteria=this.getSession().createCriteria(DraftType.class);
		criteria.add(Restrictions.eq("name", type));
		return criteria.list();
	}

}
